home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0399 / 73 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  13.1 KB

  1. Date: Tue, 2 Feb 93 17:20:57 PST
  2. From: hyc@hanauma.Jpl.Nasa.Gov (Howard Chu)
  3. Message-Id: <9302030120.AA03046@hanauma.JPL.NASA.GOV>
  4. To: mint@terminator.rs.itd.umich.edu
  5. Subject: Fasttext patches
  6.  
  7. I got some pretty good speedups by avoiding a lot of invocations of the
  8. gotoxy code in the really simple cases... Also, despite the fact that the
  9. tab processing looks gross, it actually is faster and more compact than
  10. the equivalent gotoxy compilation. I last sent this code out for mint 0.96,
  11. but it didn't seem to make it into .97 or .98... (Oh, and there was a typo
  12. in the stuff I sent out for 0.96 causing it to work incorrectly on color
  13. resolutions. It's fixed in this patch.)
  14.  
  15. I also changed paint16m to paint816m, because I like to use the 8 row high
  16. font in monochrome to get twice as many text lines per screen. Unfortunately
  17. you can't do hardware scrolling if you do this. (Perhaps, since the output
  18. might already be buffered, the code could scroll two lines at a time then? I
  19. haven't investigated that route...)
  20.  
  21. *** fasttext.c    Wed Dec 23 12:44:06 1992
  22. --- ../src/fasttext.c    Tue Feb  2 17:16:51 1993
  23. ***************
  24. *** 24,28 ****
  25.   static void paint P_((SCREEN *, int, char *)),
  26.        paint8c P_((SCREEN *, int, char *)),
  27. !      paint16m P_((SCREEN *, int, char *));
  28.   
  29.   INLINE static void curs_off P_((SCREEN *)), curs_on P_((SCREEN *));
  30. --- 24,28 ----
  31.   static void paint P_((SCREEN *, int, char *)),
  32.        paint8c P_((SCREEN *, int, char *)),
  33. !      paint816m P_((SCREEN *, int, char *));
  34.   
  35.   INLINE static void curs_off P_((SCREEN *)), curs_on P_((SCREEN *));
  36. ***************
  37. *** 51,54 ****
  38. --- 51,55 ----
  39.   static short hardline;
  40.   static void (*vpaint) P_((SCREEN *, int, char *));
  41. + static char *rowoff;
  42.   
  43.   void init P_((void));
  44. ***************
  45. *** 137,140 ****
  46. --- 138,142 ----
  47.       char *data, *foo;
  48.       static char chardata[256*16];
  49. +     register int linelen;
  50.   
  51.       foo = lineA0();
  52. ***************
  53. *** 145,149 ****
  54.          Erling
  55.       */
  56. !     scrnsize = (v->maxy+1)*(long)v->linelen;
  57.       if (hardscroll == -1) {
  58.       /* request for auto-setting */
  59. --- 147,162 ----
  60.          Erling
  61.       */
  62. !     linelen = v->linelen;
  63. !     scrnsize = (v->maxy+1)*(long)linelen;
  64. !     rowoff = (char *)kmalloc((long)((v->maxy+1) * sizeof(long)));
  65. !     if (rowoff == 0) {
  66. !         FATAL("Insufficient memory for screen offset table!");
  67. !     } else {
  68. !         long off, *lptr = (long *)rowoff;
  69. !         for (i=0, off=0; i<=v->maxy; i++) {
  70. !             *lptr++ = off;
  71. !             off += linelen;
  72. !         }
  73. !     }
  74.       if (hardscroll == -1) {
  75.       /* request for auto-setting */
  76. ***************
  77. *** 177,187 ****
  78.               }
  79.           }
  80. !     } else if (v->cheight == 16 && v->planes == 1) {
  81.           foo = &chardata[0];
  82. !         vpaint = paint16m;
  83.           for (i = 0; i < 256; i++) {
  84.               chartab[i] = foo;
  85.               data = v->fontdata + i;
  86. !             for (j = 0; j < 16; j++) {
  87.                   *foo++ = *data;
  88.                   data += v->form_width;
  89. --- 190,200 ----
  90.               }
  91.           }
  92. !     } else if ((v->cheight == 16 || v->cheight == 8) && v->planes == 1) {
  93.           foo = &chardata[0];
  94. !         vpaint = paint816m;
  95.           for (i = 0; i < 256; i++) {
  96.               chartab[i] = foo;
  97.               data = v->fontdata + i;
  98. !             for (j = 0; j < v->cheight; j++) {
  99.                   *foo++ = *data;
  100.                   data += v->form_width;
  101. ***************
  102. *** 231,242 ****
  103.       if (y == v->maxy)
  104.           place += scrnsize - v->linelen;
  105. !     else if (y) /* Yo, the screen might be bigger than 32767 bytes...
  106. !                Do a cast to long.    Erling. */
  107. !         place += (long)y * v->linelen;
  108. !     if ((j = v->planes) > 1) {
  109.           i = (x & 0xfffe);
  110. !         while (--j > 0)
  111. !             place += i;
  112.       }
  113.       return place;
  114. --- 244,256 ----
  115.       if (y == v->maxy)
  116.           place += scrnsize - v->linelen;
  117. !     else if (y) {
  118. !         y+=y;    /* Make Y into index for longword array. */
  119. !         y+=y;    /* Two word-size adds are faster than a 2-bit shift. */
  120. !         place += *(long *)(rowoff + y);
  121. !     }
  122. !     if ((j = v->planes-1)) {
  123.           i = (x & 0xfffe);
  124. !         do place += i;
  125. !         while (--j);
  126.       }
  127.       return place;
  128. ***************
  129. *** 246,251 ****
  130.    * paint(v, c, place): put character 'c' at position 'place' on screen
  131.    * v. It is assumed that x, y are proper coordinates!
  132. !  * Specialized versions (paint8c and paint16m) of this routine follow;
  133. !  * they assume 8 line high characters, medium res. and 16 line/mono,
  134.    * respectively.
  135.    */
  136. --- 260,265 ----
  137.    * paint(v, c, place): put character 'c' at position 'place' on screen
  138.    * v. It is assumed that x, y are proper coordinates!
  139. !  * Specialized versions (paint8c and paint816m) of this routine follow;
  140. !  * they assume 8 line high characters, medium res. and 8 or 16 line/mono,
  141.    * respectively.
  142.    */
  143. ***************
  144. *** 398,402 ****
  145.   
  146.   static void
  147. ! paint16m(v, c, place)
  148.       SCREEN *v;
  149.       int c;
  150. --- 412,416 ----
  151.   
  152.   static void
  153. ! paint816m(v, c, place)
  154.       SCREEN *v;
  155.       int c;
  156. ***************
  157. *** 431,434 ****
  158. --- 445,450 ----
  159.           place += vplanesiz;
  160.           *place = d;
  161. +         if (v->cheight == 8)
  162. +         return;
  163.           place += vplanesiz;
  164.           *place = d;
  165. ***************
  166. *** 487,490 ****
  167. --- 503,510 ----
  168.           d = *data++;
  169.           *place = d;
  170. +         if (v->cheight == 8)
  171. +             return;
  172.           place += vplanesiz;
  173.   
  174. ***************
  175. *** 566,569 ****
  176. --- 586,593 ----
  177.           d = ~*data++;
  178.           *place = d;
  179. +         if (v->cheight == 8)
  180. +             return;
  181.           place += vplanesiz;
  182.   
  183. ***************
  184. *** 644,648 ****
  185.       /* Hey, again the screen might be bigger than 32767 bytes.
  186.          Do another cast... */
  187. !     dst = (int *)(base + ((long)r * v->linelen));
  188.       if (v->bgcol == 0)
  189.         zero((char *)dst, v->linelen);
  190. --- 668,674 ----
  191.       /* Hey, again the screen might be bigger than 32767 bytes.
  192.          Do another cast... */
  193. !     r += r;
  194. !     r += r;
  195. !     dst = (int *)(base + *(long *)(rowoff+r));
  196.       if (v->bgcol == 0)
  197.         zero((char *)dst, v->linelen);
  198. ***************
  199. *** 748,761 ****
  200.       if (hardline < hardscroll) { /* just move the screen */
  201.           base += v->linelen;
  202. !         v->cursaddr = PLACE(v, v->cx, v->cy);
  203. !         Setscreen(base, base, -1);
  204. !     }
  205. !     else {
  206.           hardline = 0;
  207.           quickmove(hardbase, base + v->linelen, scrnsize - v->linelen);
  208.           base = hardbase;
  209. -         v->cursaddr = PLACE(v, v->cx, v->cy);
  210. -         Setscreen(hardbase, hardbase, -1);
  211.       }
  212.   }
  213.   
  214. --- 774,784 ----
  215.       if (hardline < hardscroll) { /* just move the screen */
  216.           base += v->linelen;
  217. !     } else {
  218.           hardline = 0;
  219.           quickmove(hardbase, base + v->linelen, scrnsize - v->linelen);
  220.           base = hardbase;
  221.       }
  222. +     v->cursaddr = PLACE(v, v->cx, v->cy);
  223. +     Setscreen(base, base, -1);
  224.   }
  225.   
  226. ***************
  227. *** 781,787 ****
  228.           }
  229.           nbytes = scrnsize - v->linelen;
  230.       }
  231. -     else
  232. -         nbytes = (long)v->linelen * (v->maxy - r);
  233.   
  234.       /* Sheeze, how many times do we really have to cast... 
  235. --- 804,813 ----
  236.           }
  237.           nbytes = scrnsize - v->linelen;
  238. +     } else {
  239. +         register int i = v->maxy - r;
  240. +         i += i;
  241. +         i += i;
  242. +         nbytes = *(long *)(rowoff+i);
  243.       }
  244.   
  245.       /* Sheeze, how many times do we really have to cast... 
  246. ***************
  247. *** 789,793 ****
  248.       */
  249.   
  250. !     dst = (long *)(base + ((long)r * v->linelen));
  251.       src = (long *)( ((long)dst) + v->linelen);
  252.   
  253. --- 815,821 ----
  254.       */
  255.   
  256. !     r += r;
  257. !     r += r;
  258. !     dst = (long *)(base + *(long *)(rowoff + r));
  259.       src = (long *)( ((long)dst) + v->linelen);
  260.   
  261. ***************
  262. *** 809,823 ****
  263.   {
  264.       long *src, *dst;
  265. !     int i, limit;
  266.   
  267. !     limit = v->maxy;
  268. !     for (i = limit-1; i >= r ; --i) {
  269.       /* move line i to line i+1 */
  270. !     /* AND do some casting to support big screens.
  271. !        Erling
  272. !     */
  273. !         src = (long *)(base + ((long)i * v->linelen));
  274. !         dst = (long *)(base + ((i+1)*(long)v->linelen));
  275. !         quickmove(dst, src, v->linelen);
  276.       }
  277.   
  278. --- 837,855 ----
  279.   {
  280.       long *src, *dst;
  281. !     int i, j, linelen;
  282.   
  283. !     i = v->maxy - 1;
  284. !     i += i;
  285. !     i += i;
  286. !     j = r+r;
  287. !     j += j;
  288. !     linelen = v->linelen;
  289. !     src = (long *)(base + *(long *)(rowoff + i));
  290. !     dst = (long *)((long)src + linelen);
  291. !     for (; i >= j ; i -= 4) {
  292.       /* move line i to line i+1 */
  293. !         quickmove(dst, src, linelen);
  294. !         dst = src;
  295. !         src = (long *)((long) src - linelen);
  296.       }
  297.   
  298. ***************
  299. *** 864,887 ****
  300.       (*vpaint)(v, c, v->cursaddr);
  301.       state = normal_putch;
  302. -     v->cx++;
  303. -     if (v->cx > v->maxx) {
  304. -         if (v->flags & FWRAP) {
  305. -             v->cx = 0;
  306. -             normal_putch(v, '\n');
  307. -             v->cursaddr = PLACE(v, v->cx, v->cy);
  308. -         } else {
  309. -             v->cx = v->maxx;
  310. -         }
  311. -     } else {
  312. - #if 0
  313. -         v->cursaddr = PLACE(v, v->cx, v->cy);
  314. - #else
  315. -         v->cursaddr++;
  316. -         if ( (v->cx & 1) == 0 && v->planes > 1) { /* new word */
  317. -             short skipwords = v->planes - 1;
  318. -             v->cursaddr += skipwords+skipwords;
  319. -         }
  320. - #endif
  321. -     }
  322.   }
  323.   
  324. --- 896,899 ----
  325. ***************
  326. *** 895,898 ****
  327. --- 907,911 ----
  328.       int c;
  329.   {
  330. +     int i;
  331.       int cx, cy;
  332.   
  333. ***************
  334. *** 901,914 ****
  335.       switch (c) {
  336.       case 'A':        /* cursor up */
  337. !         gotoxy(v, cx, cy-1);
  338.           break;
  339.       case 'B':        /* cursor down */
  340. !         gotoxy(v, cx, cy+1);
  341.           break;
  342.       case 'C':        /* cursor right */
  343. !         gotoxy(v, cx+1, cy);
  344.           break;
  345.       case 'D':        /* cursor left */
  346. !         gotoxy(v, cx-1, cy);
  347.           break;
  348.       case 'E':        /* clear home */
  349. --- 914,943 ----
  350.       switch (c) {
  351.       case 'A':        /* cursor up */
  352. !         if (cy) {
  353. ! moveup:            v->cy = --cy;
  354. !             v->cursaddr -= v->linelen;
  355. !         }
  356.           break;
  357.       case 'B':        /* cursor down */
  358. !         if (cy < v->maxy) {
  359. !             v->cy = ++cy;
  360. !             v->cursaddr += v->linelen;
  361. !         }
  362.           break;
  363.       case 'C':        /* cursor right */
  364. !         if (cx < v->maxx) {
  365. !             if ((i = v->planes-1) && (cx & 1))
  366. !                 v->cursaddr += i + i;
  367. !             v->cx = ++cx;
  368. !             v->cursaddr++;
  369. !         }
  370.           break;
  371.       case 'D':        /* cursor left */
  372. !         if (cx) {
  373. !             v->cx = --cx;
  374. !             v->cursaddr--;
  375. !             if ((i = v->planes-1) && (cx & 1))
  376. !                 v->cursaddr -= i + i;
  377. !         }
  378.           break;
  379.       case 'E':        /* clear home */
  380. ***************
  381. *** 916,920 ****
  382.           /* fall through... */
  383.       case 'H':        /* cursor home */
  384. !         gotoxy(v, 0, 0);
  385.           break;
  386.       case 'I':        /* cursor up, insert line */
  387. --- 945,950 ----
  388.           /* fall through... */
  389.       case 'H':        /* cursor home */
  390. !         v->cx = 0; v->cy = 0;
  391. !         v->cursaddr = base;
  392.           break;
  393.       case 'I':        /* cursor up, insert line */
  394. ***************
  395. *** 923,927 ****
  396.           }
  397.           else
  398. !             gotoxy(v, cx, cy-1);
  399.           break;
  400.       case 'J':        /* clear below cursor */
  401. --- 953,957 ----
  402.           }
  403.           else
  404. !             goto moveup;
  405.           break;
  406.       case 'J':        /* clear below cursor */
  407. ***************
  408. *** 932,940 ****
  409.           break;
  410.       case 'L':        /* insert a line */
  411. !         gotoxy(v, 0, cy);
  412.           insert_line(v, cy);
  413.           break;
  414.       case 'M':        /* delete line */
  415. !         gotoxy(v, 0, cy);
  416.           delete_line(v, cy);
  417.           break;
  418. --- 962,976 ----
  419.           break;
  420.       case 'L':        /* insert a line */
  421. !         v->cx = 0;
  422. !         i = cy + cy;
  423. !         i += i;
  424. !         v->cursaddr = base + *(long *)(rowoff + i);
  425.           insert_line(v, cy);
  426.           break;
  427.       case 'M':        /* delete line */
  428. !         v->cx = 0;
  429. !         i = cy + cy;
  430. !         i += i;
  431. !         v->cursaddr = base + *(long *)(rowoff + i);
  432.           delete_line(v, cy);
  433.           break;
  434. ***************
  435. *** 971,975 ****
  436.           break;
  437.       case 'l':        /* clear line */
  438. !         gotoxy(v, 0, cy);
  439.           clrline(v, cy);
  440.           break;
  441. --- 1007,1014 ----
  442.           break;
  443.       case 'l':        /* clear line */
  444. !         v->cx = 0;
  445. !         i = cy + cy;
  446. !         i += i;
  447. !         v->cursaddr = base + *(long *)(rowoff + i);
  448.           clrline(v, cy);
  449.           break;
  450. ***************
  451. *** 1028,1031 ****
  452. --- 1067,1072 ----
  453.       int c;
  454.   {
  455. +     register int i;
  456.   /* control characters */
  457.       if (c < ' ') {
  458. ***************
  459. *** 1032,1036 ****
  460.           switch (c) {
  461.           case '\r':
  462. !             gotoxy(v, 0, v->cy);
  463.               return;
  464.           case '\n':
  465. --- 1073,1080 ----
  466.           switch (c) {
  467.           case '\r':
  468. ! col0:            v->cx = 0;
  469. !             i = v->cy + v->cy;
  470. !             i += i;
  471. !             v->cursaddr = base + *(long *)(rowoff + i);
  472.               return;
  473.           case '\n':
  474. ***************
  475. *** 1037,1046 ****
  476.               if (v->cy == v->maxy) {
  477.                   scroll(v);
  478.               }
  479. -             else
  480. -                 gotoxy(v, v->cx, v->cy+1);
  481.               return;
  482.           case '\b':
  483. !             gotoxy(v, v->cx-1, v->cy);
  484.               return;
  485.           case '\007':        /* BELL */
  486. --- 1081,1096 ----
  487.               if (v->cy == v->maxy) {
  488.                   scroll(v);
  489. +             } else {
  490. +                 v->cy++;
  491. +                 v->cursaddr += v->linelen;
  492.               }
  493.               return;
  494.           case '\b':
  495. !             if (v->cx) {
  496. !                 v->cx--;
  497. !                 v->cursaddr--;
  498. !                 if ((i = v->planes-1) && (v->cx & 1))
  499. !                     v->cursaddr -= i+i;
  500. !             }
  501.               return;
  502.           case '\007':        /* BELL */
  503. ***************
  504. *** 1051,1055 ****
  505.               return;
  506.           case '\t':
  507. !             gotoxy(v, (v->cx + 8) & ~7, v->cy);
  508.               return;
  509.           default:
  510. --- 1101,1124 ----
  511.               return;
  512.           case '\t':
  513. !             if (v->cx < v->maxx) {
  514. !                 register union {
  515. !                     long l;
  516. !                     short i[2];
  517. !                 } j;
  518. !                 j.l = 0;
  519. !                 j.i[1] = 8 - (v->cx & 7);
  520. !                 v->cx += j.i[1];
  521. !                 if (v->cx - v->maxx > 0) {
  522. !                     j.i[1] = v->cx - v->maxx;
  523. !                     v->cx = v->maxx;
  524. !                 }
  525. !                 v->cursaddr += j.l;
  526. !                 if ((i = v->planes-1)) {
  527. !                     if (j.l & 1)
  528. !                         j.i[1]++;
  529. !                     do v->cursaddr += j.l;
  530. !                     while (--i);
  531. !                 }
  532. !             }
  533.               return;
  534.           default:
  535. ***************
  536. *** 1062,1068 ****
  537.       if (v->cx > v->maxx) {
  538.           if (v->flags & FWRAP) {
  539. -             v->cx = 0;
  540.               normal_putch(v, '\n');
  541. !             v->cursaddr = PLACE(v, v->cx, v->cy);
  542.           } else {
  543.               v->cx = v->maxx;
  544. --- 1131,1136 ----
  545.       if (v->cx > v->maxx) {
  546.           if (v->flags & FWRAP) {
  547.               normal_putch(v, '\n');
  548. !             goto col0;
  549.           } else {
  550.               v->cx = v->maxx;
  551. ***************
  552. *** 1069,1081 ****
  553.           }
  554.       } else {
  555. - #if 0
  556. -         v->cursaddr = PLACE(v, v->cx, v->cy);
  557. - #else
  558.           v->cursaddr++;
  559. !         if ( (v->cx & 1) == 0 && v->planes > 1) { /* new word */
  560. !             short skipwords = v->planes - 1;
  561. !             v->cursaddr += skipwords+skipwords;
  562. !         }
  563. ! #endif
  564.       }
  565.   }
  566. --- 1137,1143 ----
  567.           }
  568.       } else {
  569.           v->cursaddr++;
  570. !         if ((i = v->planes-1) && !(v->cx & 1))    /* new word */
  571. !             v->cursaddr += i + i;
  572.       }
  573.   }
  574.